package cn.fx.feign;

import cn.fx.domain.Product;
import cn.fx.util.JsonResult;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

@Component
public class ProductFallbackFactory implements FallbackFactory<ProductFeignClient> {

    // 此方法创建降级类
    @Override
    public ProductFeignClient create(Throwable throwable) {
        return new ProductFeignClient() {
            @Override
            public JsonResult save(Product product) {
                return JsonResult.me().setMsg("开启熔断");
            }

        };
    }
}
